/*     */ package ext.generic.integration.sourcing.task;
/*     */ 
/*     */ import com.infoengine.SAK.Task;
/*     */ import com.infoengine.object.IeAtt;
/*     */ import com.infoengine.object.IeDatum;
/*     */ import com.infoengine.object.IeGroup;
/*     */ import com.infoengine.object.IeObject;
/*     */ import com.infoengine.object.factory.Group;
/*     */ import com.infoengine.util.IEException;
/*     */ import java.io.IOException;
/*     */ import java.io.PrintStream;
/*     */ import java.util.Enumeration;
/*     */ import java.util.LinkedHashMap;
/*     */ import java.util.Map;
/*     */ 
/*     */ public class QuerySupplierInfoIETask
/*     */ {
/*  17 */   private static final String CLASSNAME = QuerySupplierInfoIETask.class.getName();
/*     */ 
/*  19 */   private static String ieXMLFileQuery = "ext/generic/erp/SupplierInfoQuery.xml";
/*     */ 
/*     */   public static Map<String, String> queryLikeName(String name)
/*     */   {
/*  30 */     System.out.println("Debug   start... " + CLASSNAME + "开始查询数据库...");
/*     */ 
/*  32 */     Group group = null;
/*     */ 
/*  34 */     String where = "";
/*     */ 
/*  36 */     if ((name != null) && (!name.trim().isEmpty()))
/*     */     {
/*  38 */       where = "vendor_name='*" + name + "*' ";
/*     */     }
/*     */ 
/*  41 */     group = createTask(where);
/*     */ 
/*  44 */     Map map = quetySupplierInfo(group);
/*     */ 
/*  46 */     if (map != null)
/*  47 */       System.out.println("Debug   end... " + CLASSNAME + "查询到的供应商信息：" + map.size());
/*     */     else {
/*  49 */       System.out.println("Debug   end... " + CLASSNAME + "没有查询到供应商信息...");
/*     */     }
/*     */ 
/*  52 */     return map;
/*     */   }
/*     */ 
/*     */   protected static Group createTask(String where)
/*     */   {
/*  63 */     System.out.println("Debug   " + CLASSNAME + "查询创建的where条件：" + where);
/*     */ 
/*  65 */     Group group = null;
/*     */ 
/*  67 */     if (where == null) {
/*  68 */       return group;
/*     */     }
/*     */ 
/*  72 */     Task task = new Task(ieXMLFileQuery);
/*     */ 
/*  74 */     task.addParam("WHERE", where);
/*     */     try
/*     */     {
/*  78 */       task.invoke();
/*     */     } catch (IEException e) {
/*  80 */       e.printStackTrace();
/*     */     } catch (IOException e) {
/*  82 */       e.printStackTrace();
/*     */     }
/*     */ 
/*  86 */     group = task.getGroup("QueryObjects");
/*     */ 
/*  88 */     return group;
/*     */   }
/*     */ 
/*     */   protected static Map<String, String> quetySupplierInfo(Group group)
/*     */   {
/*  99 */     Map map = new LinkedHashMap();
/*     */ 
/* 101 */     if (group == null) {
/* 102 */       return map;
/*     */     }
/* 104 */     int count = group.getElementCount();
/*     */ 
/* 106 */     if (count > 0) {
/* 107 */       IeGroup ieGroup = group.getGroup();
/*     */ 
/* 109 */       Enumeration children = ieGroup.getChildren();
/* 110 */       if (children != null)
/*     */       {
/* 112 */         int i = 1;
/* 113 */         while (children.hasMoreElements()) {
/* 114 */           IeObject ieRecord = (IeObject)children.nextElement();
/*     */ 
/* 117 */           IeDatum vendorIdIeDatum = ieRecord.getAtt("vendor_id").getDatum();
/* 118 */           IeDatum vendorNameIeDatum = ieRecord.getAtt("vendor_name").getDatum();
/*     */ 
/* 120 */           String vendorId = vendorIdIeDatum.rawValueOf().toString();
/* 121 */           String vendorName = vendorNameIeDatum.rawValueOf().toString();
/*     */ 
/* 124 */           map.put(vendorId, vendorName);
/*     */         }
/*     */       }
/*     */     }
/*     */ 
/* 129 */     return map;
/*     */   }
/*     */ }

/* Location:           D:\360极速浏览器下载\
 * Qualified Name:     ext.generic.integration.sourcing.task.QuerySupplierInfoIETask
 * JD-Core Version:    0.6.2
 */